FlyTalk.views.SearchPostView = Ext.extend(Ext.Panel, {	
	title: 'Posts',
	initComponent: function () {
		
		this.backButton = new Ext.Button({
			text: 'Back',
			ui: 'back',
			handler: this.backButtonTap,
			scope: this
		});
	
		this.postToolbar = new Ext.Toolbar({
			title: 'Thread',
			items:[
				this.backButton,
				{ xtype: 'spacer' },
			]
		});
		
		this.MixedStore = new Ext.data.JsonStore({
			model : 'MixedPostModel',
		});
		
		this.tweetList = new Ext.List({
			//fullscreen: false,
			//width: 320,
			//cls: 'feeds',
			scroll: true,
			emptyText: '<div style="margin:5px;">No tweets cached.</div>',
			itemTpl : [ 
                   '<div id="touchpoint_container_{type}_{answered}">',
                        '<tpl for=".">',
                            '<div class="touchpoint_data">',
								'<div class="touchpoint_icon">',
									'<img width="44" height="44" src="{image_url}"/>',
								'</div>',
                            
								'<div class="touchpoint_content_{type}">',
									'<span class="touchpoint" style="padding-right: 10px">{from_user}</span>{flight}<br />',
									 '{text}',
									'<div style="color:#999; font-size: 11px;">{language}</div>',
									
								'</div>',
							
							'<div class="plus_{answered}" >',
								'<img src="images/plus_post.png" width="30px" height="30px"  style="position: relative; top: 12px">',
							'</div>',
							
							'<div style="padding: 2px; color:#999; font-size: 11px; float: left; width: 150px;">',
								
								'<div >',
								
									'<div style="padding-right:10px; float:left">{date}</div>',
									'<div style="padding-right:10px; float:left">{up} <img src="images/thumbsUP_postscopy{rated}.png" width="10px" /> / {down} <img src="images/thumbsDown_postscopy{rated}.png" width="10px" /></div>',
									'{tp}',
									'<div style="padding-right:10px; float:left">{followed}</div>',
									//'<div style="padding-right:10px; float:left">{followed}</div>',
								'</div>',
	
									
							'</div>',
							
							'<div class="clear"></div>',
							
                            '</div>',
                        '</tpl>',
                    '</div>'
			],
			grouped : false,
			indexBar: false,
			width: 320,
			flex:1,
		//	onItemDisclosure: true,
			store: this.MixedStore,			
	
			listeners:{
				itemTap: function(dv, index, tweet, e){
					if(e.getTarget('.touchpoint_icon')){
						alert("click image");
						// need to link to public profile
					}
					else if(e.getTarget('.plus_') || e.getTarget('.plus_yes')){
						//alert("clicked on +");
						FlyTalk.views.TalkView.tweetToolbar.title = "search";
						//FlyTalk.views.SearchPostView.onMenu(index);	
						FlyTalk.views.BoredView.incomplete.show();
					}	
				},
			},
		});	
		
      //  this.dockedItems = [this.postToolbar];
		this.items = [this.tweetList];

        FlyTalk.views.SearchPostView.superclass.initComponent.call(this);
    },

    backButtonTap: function () {
    	// link to next page
		var next = FlyTalk.views.TalkView.tweetToolbar.title; // see which page talk is on right now
		Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openNext',
            next: next,
        });
    },
    
    onMenu: function (ind) {
        Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openSearchMenu',
           // post: record,
            index: ind,
        });
    },

});